/<template>
  <div class="alljob">
      <p @click="$router.back()">返回</p>
    <div class="top">
      <ul>
        <li>类型</li>
        <li>区域</li>
        <li>
          <span @click="sheng">升序</span> |
          <span @click="jiang">降序</span>
        </li>
        <li>筛选</li>
      </ul>
    </div>
    <div class="con">
      <div>
        <ul>
          <li v-for="(item, index) in list" :key="index">
            <p>
              <b>{{ item.title }}</b>
              <span>{{ item.city }}</span>
            </p>
            <p>
              <span style="color: #f60"
                ><i>{{ item.price }}</i
                >/天</span
              >
            </p>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      list: [],
    };
  },
  methods: {
   sheng(){//升序方法
     this.list=this.list.sort((a,b)=>{
              return a.price-b.price
          })
   },
    jiang(){//降序方法
            this.list=this.list.sort((a,b)=>{
              return b.price-a.price
          })
      }
  },
  mounted() {//获取list数据
    axios.get("/list").then((res) => {
      console.log(res.data)
      this.list = res.data;
    });
  },
};
</script>

<style lang="scss">
.alljob {
  width: 100%;
  height: 100%;
  .top {
    width: 100%;
    height: 0.5rem;
    ul {
      width: 100%;
      height: 0.5rem;
      display: flex;
      justify-content: space-around;
      align-items: center;
    }
  }
  .con {
    flex: 1;
    overflow-y: scroll;
    div {
      width: 100%;
      height: auto;
      ul {
        li {
          width: 100%;
          height: 0.5rem;
          border-bottom: 1px solid #ccc;
          display: flex;
          justify-content: space-between;
          p {
            width: 50%;
            height: 0.5rem;
          }
        }
      }
    }
  }
}
</style>